<template>
	<view>
		<view class="" v-if="searchList.length > 0">
			<uni-card v-for="(item,index) in searchList" :key="item.communityId" >
				<view class="searchName"  @click="navRouter(`../details?id=${item.communityId}&title=${item.communityName}&type=${type}`)">
					{{item.communityName}}
					<view class="searchNum">
						{{item.elevatorInfoNum}}
						<text>
							部电梯
						</text>
					</view>
				</view>
			</uni-card>
		</view>
		
		<view v-else>
			<null-page></null-page>
		</view>
	</view>
</template>

<script>
	
	
	import nullPage from '@/common/null.vue'
	import polling from "@/serve/api/polling.js";
	export default {
		components:{
			nullPage,
		},
		data() {
			return {
				searchList:[
				
				],
				communityName:"",
				pageNum: 1,
				getListFlag:true,
				type:'',
			}
		},
		onLoad(e) {
			this.type = e.type
			this.communityName = e.communityName
			this.getpollingList();
		},
		methods: {
			async getpollingList() {
				let parme = {
					communityName:this.communityName,
					pageNum: this.pageNum,
					pageSize: 20,
				}
				const res = await polling.findCommunityByToken(parme)
				if (res.data.data.list.length < 10 && this.searchList.length > 0) {
					uni.showToast({
						title: '已加载全部',
						icon: 'none'
					})
				}
				this.searchList = this.searchList.concat(res.data.data.list)
				// this.searchList.push(...res.data.data.list)
			},
		
			
		
		},
		onReachBottom(e) {
			if (this.getListFlag) {
				this.pageNum = this.pageNum + 1;
				this.getpollingList();
			}
		
		}
	}
</script>

<style scoped>
	.uni-card{
		border: none;	
		background: #FFFFFF;
		width: 670rpx;
		height: 108rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 20rpx;
	
	}
	.searchName{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #34363D;

	}
	.searchNum{
		font-size: 40rpx;
		font-family: Arial;
		font-weight: bold;
		color: #017EFE;

	}
	.searchNum text{
		color: #989BA6;
		font-size: 24rpx;
	}
</style>
